<template>
  <view>
    <u-dropdown>
      <u-dropdown-item v-model="value_1" title="级别" :options="options1" @change="change()"></u-dropdown-item>
      <u-dropdown-item v-model="value_2" title="类别" :options="options2" @change="change()"></u-dropdown-item>
    </u-dropdown>
    <view class="act_list u-line-1" v-for="item in items" v-if="provider=='weixin'" @click="goRetru(item.rId,item.name)">
      <view class="inf_img">
        <u-image :src="item.indexImg||'https://hd.jxj777.top/usr/img/bj5.jpg'" width="100%" height="100%" mode="aspectFill" class="indexImg" title="22132"></u-image>
      </view>
      <view id="inf_name" class="inf">
        <text style="font-size: 30rpx;font-weight: bold;">{{ item.name }}</text>
        </br>
      </view>
      <view v-if="item.intro" id="inf_intro" class="inf" role="presentation">{{item.intro}}</view>
    </view>
    <view class="act_list u-line-1" v-for="item in items" v-else @click="goRetru(item.rid,item.name,item.class_one)">
      <view class="inf_img">
        <cover-image :src="item.indexImg||'https://hd.jxj777.top/usr/img/bj5.jpg'" mode="aspectFit" class="indexImg" title="22132"></cover-image>
      </view>
      <view id="inf_name" class="inf">
        <h3>{{ item.name }}</h3>
      </view>
      <view id="inf_intro" class="inf" role="presentation">{{item.intro}}</view>
    </view>
    <view class="wrap">
      <text></text>
      <u-back-top :scroll-top="scrollTop" :icon-style="iconStyle" :custom-style="customstyle"></u-back-top>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        provider: '',
        items: [{
            name: '琴理工作室',
            indexImg: '',
            rid: '',
            intro: '琴理工作室是沈阳理工大学教务处旗下的学生开发团队.......',
            class_one: '社团',
            class_two: '',
            hot: ''
          },
          {
            name: '琴理工作室',
            indexImg: '',
            rId: '',
            intro: '琴理工作室是沈阳理工大学教务处旗下的学生开发团队.......',
            class_one: '组织',
            class_two: '',
            hot: ''
          },
          {
            name: '琴理工作室',
            indexImg: '',
            rId: '',
            intro: '琴理工作室是沈阳理工大学教务处旗下的学生开发团队.......',
            class_one: '',
            class_two: '',
            hot: ''
          },
        ],
        scrollTop: 0,
        iconStyle: {
          fontSize: '32rpx',
          color: '#99CCCC',
        },
        customstyle: {
          background: '#FFCC99'
        },
        value_1: 0,
        value_2: 0,
        options1: [{
            label: '社团',
            value: 0,
          },
          {
            label: '组织',
            value: 1,
          },
        ],
        options2: [{
            label: '学术科技',
            value: 0,
          },
          {
            label: '志愿服务',
            value: 1,
          },
          {
            label: '组织办公',
            value: 2,
          },
          {
            label: '创新创业',
            value: 4,
          },
          {
            label: '文化体育',
            value: 5,
          },
        ],
      }
    },
    onPageScroll(e) {
      this.scrollTop = e.scrollTop;
    },
    onLoad() {
      // console.log(uni.getStorageSync('provider'));
      let that = this
      this.provider = uni.getStorageSync('provider')
      // 第一次请求列表
      this.$request({
        method: 'GET',
        url: '/organization/allorgmsg',
        header: {
          'Content-Type': 'application/x-www-form-urlencoded'
        },
      }).then(res => {
        console.log(res.data)
        console.log(this)
        that.items = res.data
      }).catch(res => {
        console.log(res)
        // 失败后执行
        console.log('reserror')
      })
    },
    methods: {
      goRetru(id, title, cl) {
        console.log(id)
        if (cl != "社团") {
          uni.navigateTo({
            url: '/pages/recru/recru?id=' + id + '+&title=' + title + '&class=' + cl
          })
        } else {
          uni.navigateTo({
            url: '/pages/stReture/stReture?id=' + id + '+&title=' + title + '&class=' + cl
          })
        }
      },
      close(index) {
        console.log(index)
        console.log(this.value_1)
        // 关闭的时候，给当前项加上高亮
        // 当然，您也可以通过监听dropdown-item的@change事件进行处理
        this.$refs.uDropdown.highlight(index);
      },
      change() {
        let that = this
        let num_one = this.value_1
        let num_two = this.value_2
        // 更改类别请求
        this.$request({
          method: 'GET', // 默认GET
          url: '/orgclass',
          data: {
            class_one: this.options1[num_one].label,
            class_two: this.options2[num_two].label
          },
          header: {
            'Content-Type': 'application/x-www-form-urlencoded',
            // 'Authorization': "Bearer" + this.getToken
          },
        }).then(res => {
          // 成功后执行，具体格式待对完接口完善
          console.log(res)
          if (res.code == 200) {
            that.items = res.data
          }
        }).catch(res => {
          // 失败后执行
        })
      }
    }
  }
</script>

<style>
  @import url("../../style/list.css");
</style>
